import datetime

from sqlalchemy import select

from mall.models.member import Member
from mall.models.shop_cart import ShopCart


def init_shop_cart_data(engine):

    conn = engine.connect()
    conn.execute(ShopCart.__table__.delete())
    resule = conn.execute(select([Member]))

    member = [[m[0] for m in resule]]

    i = 0
    for m in member:
        i += 1
        conn.execute(
            id = i,
            member_id = m,
            updated_at=datetime.datetime.now(),
            created_at=datetime.datetime.now(),
            status='normal'
        )
